<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <meta HTTP-EQUIV="Expires" CONTENT="0">
    <link rel="shortcut icon" href="/rucdbcourse/views/images/ruc_logo_icon.jpg">
    <title>数据库系统概论实验评分系统</title>
    <link href="/rucdbcourse/views/css/register/basic.css" rel="stylesheet">
    <link href="/rucdbcourse/views/css/register/style.css" rel="stylesheet">
    <link href="/rucdbcourse/views/css/bootstrap.min.css" rel="stylesheet">
    <script type="text/javascript" src="/rucdbcourse/views/js/jquery.js"></script>
    <script type="text/javascript" src="/rucdbcourse/views/assets/layer/layer.js"></script>
    <script type="text/javascript" src="/rucdbcourse/views/lib/angular.min.js"></script>
    <script type="text/javascript" src="/rucdbcourse/views/js/vCode.js"></script>
</head>

<body class="login-body">
    <div class="header">
        <span class='header-pic'><img src="/rucdbcourse/views/images/ruc_logo.png" class="" onclick="window.location.href='/rucdbcourse'"> </span>
        <em>找回密码</em>
    </div>
    <div>
        <div class="login" ng-app="reset" ng-controller="resetCtrl">
            <div class="login_input1">
                <span>用户名</span>
                <input type="text" placeholder="请输入账号" id="USER_NAME" name="USER_NAME" ng-model="name">
            </div>
            <div class="login_input1">
                <span>邮箱</span>
                <input type="text" placeholder="请输入注册时填写的邮箱" id="email" name="email" ng-model="email">
            </div>
            <div class="login_input3">
                <span>验证码</span>
                <input style="float:left;width:60%;" type="text" name="veryCode" id="veryCode" ng-model="verifycode" placeholder="验证码">
            </div>
            <div id="vCode1" style="width:100px; height: 46px; margin-left: 20px;margin-top: 28px; border: 1px solid #ccc; display: inline-block;"></div>
            <div style="margin-top:40px">
                <button ng-click="submits()" class="btn btn-lg btn-login btn-block" id="login-btn" type="button" style="background-color:#C43C3C;color:#fff">找&nbsp;&nbsp;&nbsp;&nbsp;回</button>
            </div>
            <div class="login_tishi">
              	 已有账号？<a href="javascript:window.location.href='/rucdbcourse/'">立即登录</a>
            </div>
        </div>
    </div>
    <div class="footer">
        <div class="container">
            Copyright &copy;2005-2017 ruc.edu.cn v1.0 All Rights Reserved. 京ICP备05066828号-1
            <br>
        </div>
    </div>
    <script type="text/javascript">
    
    var app = angular.module('reset', []);
    app.controller('resetCtrl', function($scope, $http) {
    	var container1 = document.getElementById("vCode1");
		var code1 = new vCode(container1); 
    	 $scope.submits = function() {
    		
         	if($scope.name==null){
     			layer.msg('请填写用户名');
     			return false;
     		}else if($scope.email==null){
     			layer.msg('请填写邮箱');
     			return false;
     		}else if(!$("#email").val().trim().match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/)){
     			layer.msg('请填写正确的邮箱地址');	
     		}else if($scope.verifycode==null){
     			layer.msg('请填写验证码');
     			return false; 
     		}else if(!code1.verify($("#veryCode").val)){
             	layer.msg('验证码错误');
             	return false; 	
             }
     		else{
     			$("#login-btn").attr("disabled",true);
         		$("#login-btn").html("请稍后...");
                // console.log("submit")
                window.location="/rucdbcourse/views/info.html?type=3";
                /*$http.post('user/resetPassword',
                		$.param({
     					name: $scope.name,
     					mail: $scope.mail
     				}), {
     					headers: {
     					    'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
     					}
                 }).then(function(response) {
     				//debugger
     				console.log(response.data.value)
     				var result = response.data.value
     				if (result == 'success') {
     				    //debugger
     				    console.log(response.data.value);
     				    $("#login-btn").attr("disabled",false);
     					$("#login-btn").html("z&nbsp;&nbsp;&nbsp;&nbsp;录");
     				    window.location = "/rucdbcourse/views/index.html";
     				} else {
     					if(result=="passwd_err"){
                         	result="密码错误";
                         }else if(result=="user_not_exist"){
                         	result="用户不存在";
                         }else if(result=="waiting"){
                         	window.location="views/waiting.html";
                         }else if(result=="rejected"){
                         	result="您的申请已被拒绝";
                         }
     				    layer.msg(result);
     				    $("#login-btn").attr("disabled",false);
     					$("#login-btn").html("登&nbsp;&nbsp;&nbsp;&nbsp;录");
     				    console.log(response.data.msg);
     				}
     			});*/
     		}
         };
    });
    </script>
</body>

</html>
